#include "../inc/my_brush.h"
#include "../inc/lcd.h"
#include "../inc/dir.h"
#include "../inc/dlist.h"
#include "../inc/bmp.h"
#include "../inc/touch.h"


//查看文件截图的函数
void view_file_screenshot(char* user){
    int x =0;
    int y =0;
    char buf[100] = "./user_info/user";
    strcat(buf,user);
    DScreenShotNode_t* list = dir_searchToList(buf,".bmp");
    if(list->next == NULL){
        //加一个没有图片
        bmp_show("./res/interface/no_brush_3.bmp",0,0);
        usleep(500000);
        bmp_show("./res/interface/no_brush_2.bmp",0,0);
        usleep(500000);
        bmp_show("./res/interface/no_brush_1.bmp",0,0);
        usleep(500000);
        return;
    }
    DScreenShotNode_t* p = list->next;
    bmp_show(p->data.fileName,0,0);
    bmp_show_small("./res/interface/mainExit.bmp",700,0);
    while(1){
        //获取按键上的坐标
        touch_wait(&x,&y);
        if(PLACE_BRUSH_LEFT(x,y)){
            bmp_show_small("./res/interface/mainExit.bmp",700,0);
            printf("点击了BRUSH_LEFT\n");
            p = p->next;
            bmp_show(p->data.fileName,0,0);
            bmp_show_small("./res/interface/mainExit.bmp",700,0);
        }
        if(PLACE_BRUSH_RIGHT(x,y)||PLACE_BRUSH_RIGHT2(x,y)){
            bmp_show_small("./res/interface/mainExit.bmp",700,0);
            printf("点击了BRUSH_RIGHT\n");
            p = p->prev;
            bmp_show(p->data.fileName,0,0);
            bmp_show_small("./res/interface/mainExit.bmp",700,0);
        }
        if(PLACE_BRUSH_EXIT(x,y)){
            printf("点击了BRUSH_EXIT\n");
            break;
        }
    }
    // bmp_show(p->data.fileName,0,0);
    // sleep(1);    
}

